<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/views/public/include/taglib.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<!--[if IE 8]>
<html lang="zh" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<!--<![endif]-->
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>新增机构</title>
<meta name="decorator" content="decForm" />
<script type="text/javascript">
	$(document).ready(function(){
		$('#btnCancel').click(function(){
			//parent.to_page(1);//关闭前调用父页面刷新列表函数
			parent.closeDialog();//调用父页面关闭弹窗函数
		});

		$('#btnReset').click(function(){
			btnReset();
		});
		$('#btnSubmit').click(function(){
			saveDept();
		});

	});

	//重置
	function btnReset(){
		$("#deptCode").val("");
		$("#deptName").val("");
		$("#reserved1").val("");
		$("#remarks").val("");
	}
	//保存
	function saveDept(){
		if (!$("#deptCode").val()) {
			$.jBox.tip("请输入机构号！", "info");
			return false;
		}
		if (!$("#deptName").val()) {
			$.jBox.tip("请输入机构全称！", "info");
			return false;
		}
		if (!$("#reserved1").val()) {
			$.jBox.tip("请输入机构简称！", "info");
			return false;
		} else {

			addDeptAjax("${basePath}/upms/dept/add", "inputForm");
		}
	}

	//保存ajax
	function addDeptAjax(actionPath , formId){
		CommonUtils.AjaxUtil.RockAjax(actionPath, getFormJson(formId), {
			submitType : "POST",
			lazyTime : 1000,
			msgTitle : "操作结果",
			msg : "保存成功",
			wrong : "保存失败wrong",
			error : "保存失败error：",
			successCallback : function(){
				parent.to_page(1);//关闭前调用父页面刷新列表函数
				parent.closeDialog();//调用父页面关闭弹窗函数

			}

		});
	}

	//将表单数据转换为json对象,frm：form表单的id
	function getFormJson(frm){
		var o = {};
		var a = $("#" + frm).serializeArray();
		$.each(a, function(){
			if (o[this.name] !== undefined) {
				if (!o[this.name].push) {
					o[this.name] = [ o[this.name] ];
				}
				o[this.name].push(this.value || '');
			} else {
				o[this.name] = this.value || '';
			}
		});
		return o;
	}
</script>
</head>
<body>
	<div class="contentpanel">
		<div class="panel panel-default">
			<div class="panel-heading">
				<div class="panel-btns">
					<a href="#" class="minimize">−</a>
				</div>
				<h4 class="panel-title">新增机构</h4>
			</div>
			<div class="panel-body">
				<form id="inputForm" action="" method="post" class="form-horizontal">
					<div class="form-group">
						<label class="control-label col-xs-5">
							<span class="text-danger">*</span>
							机构号：
						</label>
						<div class="col-xs-5">
							<input type="text" id="deptCode" name="deptCode" value="${vo.deptCode}" class="form-control" placeholder="请输入8位机构号" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">
							<span class="text-danger">*</span>
							所属机构ID：
						</label>
						<div class="col-xs-5">
							<input type="text" id="pid" name="pid" value="${vo.pid}" class="form-control" placeholder="请输入所属机构ID" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">
							<span class="text-danger">*</span>
							机构全称：
						</label>
						<div class="col-xs-5">
							<input type="text" id="deptName" name="deptName" value="${vo.deptName}" class="form-control" placeholder="请输入机构名称" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">
							<span class="text-danger">*</span>
							简称：
						</label>
						<div class="col-xs-5">
							<input type="text" id="reserved1" name="reserved1" value="${vo.reserved1}" class="form-control" placeholder="请输入简称" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">备注：</label>
						<div class="col-xs-5">
							<input type="text" id="remarks" name="remarks" value="${vo.remarks}" class="form-control" placeholder="请输入备注信息" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">创建人：</label>
						<div class="col-xs-5">
							<input type="text" id="createUsername" name="createUsername" value="${vo.createUsername}" class="form-control" readonly="readonly" />
						</div>
					</div>
					<div class="form-group">
						<label class="control-label col-xs-5">创建时间：</label>
						<div class="col-xs-5">
							<p class="form-control-static text-left" style="text-indent: 0">
								<fmt:formatDate value="${vo.createTime}" type="both" pattern="yyyy-MM-dd HH:mm:ss" />
							</p>
						</div>
					</div>
					<div class="text-center m-15">
						<a id="btnSubmit" href="javascript:void(0);" class="btn btn-primary m-l-20">
							<i class="fa fa-save"></i>
							保存
						</a>
						<a id="btnReset" href="javascript:void(0);" class="btn btn-primary m-l-20">
							<i class="fa fa-refresh"></i>
							重置
						</a>
						<a id="btnCancel" href="javascript:void(0);" class="btn btn-primary m-l-20">
							<i class="fa fa-reply"></i>
							返回
						</a>
					</div>
				</form>
			</div>
		</div>
	</div>
</body>
</html>